﻿@model IEnumerable<LabManagement.Data.Org>

@{
    ViewBag.Title = "Organizations";
}


<div class="box">
<div class="box-title">
    @Html.ActionLink("Add New", "Create", null, new { @Class = "btn btn-primary pull-right" })
</div>
<div class="box-content nopadding">
    <table class="table table-hover table-nomargin table-bordered usertable">
       <thead>
           <tr>
               <th>
                   @Html.DisplayNameFor(model => model.OrgName)
               </th>
               <th>
                   @Html.DisplayName("Contact Name")
               </th>
               <th>
                   @Html.DisplayName("Contact Email")
               </th>
               <th></th>
           </tr>
       </thead>         
        <tbody>
            @{var i = 0; var delformId = string.Empty; }
            @foreach (var item in Model)
            {
                i++;
                delformId = "del_" + i;
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.OrgName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Contact.ContactName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Contact.ContactEmail)
                    </td>
                    <td>
                      
                        <a href="@Url.Action("edit", new { id = item.OrgId })" class="btn" rel="tooltip" title="Edit">
                            <i class="fa fa-edit"></i>
                        </a>
                        <a href="#" data-id="@delformId" class="btn deleteaction" rel="tooltip" title="Delete">
                            <i class="fa fa-times"></i>
                        </a>
                        @using (Html.BeginForm("delete", "org", new { id = @item.OrgId }, FormMethod.Post, new { id = delformId }))
                        {
                            @Html.AntiForgeryToken()
                        }
                        @Html.ActionLink("Lab Users", "index","LabUsers", new { OrgId = @item.OrgId },null)
                    </td>
                </tr>
            }
        </tbody>
        <tfoot>
            <tr>
                <td colspan="4" class="text-right">
                    Pagination will come here
                </td>
            </tr>
        </tfoot>
    </table>
</div>
</div>
  @section Scripts{
    <script type="text/javascript">
        $(".deleteaction").on("click", function () {
            if (confirm("Are you sure ? you wanted to delete this category")) {
                console.log("delCat_" + $(this).data("id"));
                $('#' + $(this).data("id")).submit();
            }
        });

    </script>
}


